package snpi;

import java.util.concurrent.atomic.AtomicInteger;

/**
 *
 * @author Trevor Brown
 */
public class SNPICASOnce implements SNPI {
    private AtomicInteger counter;
    
    public SNPICASOnce() {
        counter = new AtomicInteger(0);
    }
    
    public final int get() {
        return counter.get();
    }
    
    public final void increment(final int id) {
        final int result = counter.get();
        counter.compareAndSet(result, 1+result);
    }
    
}
